package com.adaxi.adc.business.vehicletrip.controller;

import com.adaxi.adc.business.vehicletrip.pojo.VehicleTripLocation;
import com.adaxi.adc.business.vehicletrip.service.VehicleTripLocationService;
import com.adaxi.adc.common.common.CommonResult;
import com.adaxi.adc.common.utils.UuidUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/vehicleTripLocation")
public class VehicleTripLocationController {
    @Autowired
    VehicleTripLocationService locationService;

    @PostMapping("/updateLocal")
    public CommonResult updateLocal(@RequestBody VehicleTripLocation vehicleTripLocation) {
        if(locationService.isVehicleTripId(vehicleTripLocation.getVehicleTripId())){
            locationService.updateLocal(vehicleTripLocation);
            return CommonResult.SUCCESS("更新成功");
        }else {
            vehicleTripLocation.setId(UuidUtil.get32UUID());
            locationService.save(vehicleTripLocation);
            return CommonResult.SUCCESS("新增成功");
        }

    }
}
